"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnUtils = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
bignumber_js_1.default.config({ EXPONENTIAL_AT: [-8, 30] });
const applyFunction = {
    toBigInt() {
        return BigInt(this.toString());
    },
    toHex() {
        let hex = this.dp(0).toString(16);
        if (hex === `0`)
            return `0x`;
        return `0x${hex}`;
    },
};
Object.assign(bignumber_js_1.default.prototype, applyFunction);
exports.bnUtils = {
    wrap: (tar) => {
        return new bignumber_js_1.default(typeof tar === "bigint" ? tar.toString() : tar);
    },
    toWei: (tar, decimals) => {
        return exports.bnUtils.wrap(tar).times(new bignumber_js_1.default(10).pow(exports.bnUtils.wrap(decimals)));
    },
    fromWei: (tar, decimals) => {
        return exports.bnUtils.wrap(tar).div(new bignumber_js_1.default(10).pow(exports.bnUtils.wrap(decimals)));
    },
};
